package com.candy.demo3;

import com.candy.jdbcutil.JDBCUtil;
import com.candy.pojo.Student;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class JDBCDdemo {
    public static void main(String[] args) throws Exception{
        Connection conn = JDBCUtil.getConnection();
        PreparedStatement ps = conn.prepareStatement("select * from tb_student");
        ResultSet rs = ps.executeQuery();
        List<Student> ls = new ArrayList<Student>();
        while (rs.next()){
            Student su = new Student(rs.getInt("tid"),rs.getString("name"));
            ls.add(su);
        }
        JDBCUtil.close(conn,ps,rs);
        for (Student s:ls) {
            System.out.println(s);
        }

    }
}
